/* eslint valid-jsdoc: "off" */

'use strict';
const path = require('path')

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1614435858412_3423';

  // add your middleware config here
  //config.middleware = ['m1', 'm2'];

  config.middleware = ['httpLog'];
  config.httpLog = {
    type: 'all'
  }
  config.security = {
    csrf: {
      enable: false,
    },
  };

  config.auth = {
    exclude: ['/home', '/user', '/login', '/logout']
  }
  config.view = {
    mapping: {
      ".html" : "ejs"
    },
    root: [
      path.join(appInfo.baseDir, "app/html"),
      path.join(appInfo.baseDir, "app/view"),
    ].join(',')
  }
  config.mysql = {
    app: true,
    agent: false,
    client: {
      host: '127.0.0.1',
      port: '3306',
      user: 'root',
      password: '12345678',
      database: 'egg'
    }
  }
  config.static = {
    prefix: '/assets/',
    dir: path.join(appInfo.baseDir, "app/assets")
  }
  config.ejs = {
    //delimiter: "$$"
  }
  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };
  config.session = {
    key: "Mic_SESS",
    httpOnly: true,
    maxAge: 1000 * 50,
    renew: true  // renew为true   当session为session最大缓存时间一半的时候，自动刷新session
  }
  config.sequelize = {
    dialect: 'mysql',
    host: '127.0.0.1',
    port: '3306',
    user: 'root',
    password: '12345678',
    database: 'egg',
    define: {
      timestamps: false,  // 时间不需要sequelize处理
      freezeTableName: true  // 表名称不需要sequelize来处理
    }
  }
  return {
    ...config,
    ...userConfig,
  };
};
